---
title: "Winter 2022 Thursday Hearing Screenings"
output:
flexdashboard::flex_dashboard:
orientation: rows
social: menu
source_code: embed
vertical_layout: scroll
theme:
version: 4
bg: "#101010"
fg: "#101010"
primary: "#ED79F9"
navbar-bg: "#3ADAC6"
---
```{r setup, include=FALSE}
library(flexdashboard)
```
```{r, include=FALSE}
library(tidyverse)
library(here)
library(janitor)
library(rio)
library(colorblindr)
library(gghighlight)
library(forcats)
library(ggrepel)
library(gt)
library(knitr)
library(kableExtra)
library(reactable)
library(plotly)
library(glue)
library(fs)
library(rstatix)
library(ggpubr)
library(writexl)
library(remotes)
library(profvis)
theme_set(theme_minimal(15) +
theme(legend.position = "bottom",
panel.grid.major.x = element_line(colour = "gray60"),
panel.grid.minor.x = element_blank(),
panel.grid.major.y = element_blank())
)
```
```{r, include=FALSE}
ear <- import(here("data", "hearing_screening.sav"),
setclass = "tbl_df") %>%
characterize() %>%
janitor::clean_names() %>%
mutate(grade = as.factor(grade),
school = as.factor(school),
screen_res = as.factor(screen_res))
str(ear)
ear$grade <- factor(ear$grade, levels = c("kindergarten",
"1st grade",
"2nd grade"))
ear$screen_res <- factor(ear$screen_res, levels = c("pass",
"pass with OAE",
"refer",
"absent"))
ear$school
ear$school <- factor(ear$school, levels = c("Twin Oaks",
"McCornack",
"River Road",
"Buena Vista",
"Howard"))
ear_res <- ear %>%
group_by(grade, school) %>%
count(screen_res)
ear %>%
group_by(screen_res) %>%
count()
screen_stat <- ear_res %>%
mutate(screened = screen_res == "pass" &
screen_res == "pass with OAE" &
screen_res == "refer",
absent = screen_res == "absent")
screen_stat2 <- ear %>%
group_by(screen_res, school) %>%
count() %>%
pivot_wider(
names_from = screen_res,
values_from = n
) %>%
mutate(screened = sum(`pass` + `pass with OAE` + refer),
total_passed = sum(`pass` + `pass with OAE`),
pass_pct = (total_passed / screened)) %>%
select(1, 2, 3, 7, 4, 6, 5, 8)
str(screen_stat2)
screen_stat2 <- screen_stat2 %>%
mutate_if(is.integer, as.numeric)
str(screen_stat2)
screen_stat3 <- ear %>%
group_by(screen_res, grade) %>%
count() %>%
pivot_wider(
names_from = screen_res,
values_from = n
) %>%
mutate(screened = sum(`pass` + `pass with OAE` + refer),
total_passed = sum(`pass` + `pass with OAE`),
pass_pct = (total_passed / screened)) %>%
select(1, 2, 3, 7, 4, 6, 5, 8)
screen_stat3 <- screen_stat3 %>%
mutate_if(is.integer, as.numeric)
```
# Results
Row {.tabset}
-----------------------------------------------------------------------
```{r, include=FALSE}
ear_grade <- ear %>%
group_by(grade) %>%
count()
ear_school <- ear %>%
group_by(school) %>%
count()
```
```{r, include=FALSE}
grd_tbl <- ear_grade %>%
reactable(columns = list(
grade = colDef(name = "Grade",
align = "center"),
n = colDef(name = "Total",
align = "center",
format = colFormat(suffix = " students"))
),
striped = TRUE,
outlined = TRUE,
compact = TRUE,
highlight = TRUE,
bordered = TRUE)
grd_tbl2 <- screen_stat3 %>%
reactable(
columns = list(
grade = colDef(name = "Grade",
align = "center"),
pass = colDef(name = "Total Passed with Pure Tone",
align = "center"),
`pass with OAE` = colDef(name = "Total Passed with OAE",
align = "center"),
`total_passed` = colDef(name = "Total Passed",
align = "center"),
refer = colDef(name = "Total Referred",
align = "center"),
screened = colDef(name = "Total Screened",
align = "center"),
absent = colDef(name = "Total Absent",
align = "center"),
pass_pct = colDef(name = "Pass Rate",
align = "center",
format = colFormat(percent = TRUE, digits = 2))),
striped = TRUE,
outlined = TRUE,
compact = TRUE,
highlight = TRUE,
bordered = TRUE
)
sch_tbl <- ear_school %>%
reactable(columns = list(
school = colDef(name = "School",
align = "center"),
n = colDef(name = "Total",
align = "center",
format = colFormat(suffix = " students"))
),
striped = TRUE,
outlined = TRUE,
compact = TRUE,
highlight = TRUE,
bordered = TRUE)
sch_tbl2 <- screen_stat2 %>%
reactable(
columns = list(
school = colDef(name = "School",
align = "center"),
pass = colDef(name = "Total Passed with Pure Tone",
align = "center"),
`pass with OAE` = colDef(name = "Total Passed with OAE",
align = "center"),
`total_passed` = colDef(name = "Total Passed",
align = "center"),
refer = colDef(name = "Total Referred",
align = "center"),
screened = colDef(name = "Total Screened",
align = "center"),
absent = colDef(name = "Total Absent",
align = "center"),
pass_pct = colDef(name = "Pass Rate",
align = "center",
format = colFormat(percent = TRUE, digits = 2))),
striped = TRUE,
outlined = TRUE,
compact = TRUE,
highlight = TRUE,
bordered = TRUE
)
```
### School
```{r, include=TRUE}
sch_tbl2
```
### Grade
```{r, include=TRUE}
grd_tbl2
```
Row {.tabset}
-----------------------------------------------------------------------
### Screening Results
```{r, include=FALSE}
res_tbl <- ear_res %>%
reactable(columns = list(
grade = colDef(name = "Grade",
align = "center"),
school = colDef(name = "School",
align = "center"),
screen_res = colDef(name = "Screening Result",
align = "center"),
n = colDef(name = "Total",
align = "center",
format = colFormat(suffix = " students"))),
striped = TRUE,
outlined = TRUE,
compact = TRUE,
highlight = TRUE,
bordered = TRUE,
searchable = TRUE)
```
```{r, include=TRUE}
res_tbl
```
```{r, include=FALSE}
test_scn <- screen_stat2 %>%
select(school, screened) %>%
group_by(school, screened) %>%
mutate(scr_tot = sum(screened))
test_scn %>%
adorn_totals("row")
# sch_screen <- screen_stat2 %>%
# select(school, screened) %>%
# pivot_wider(
# names_from = school,
# values_from = screened
# ) %>%
# mutate(total = sum(c_across(cols = everything()))) %>%
# mutate(pct_1 = `Twin Oaks` / total,
# pct_2 = `McCornack` / total,
# pct_3 = `River Road` / total,
# pct_4 = `Buena Vista` / total)
#?c_across
# sch_screen2 <- sch_screen %>%
# pivot_longer(
# cols = c(1:4),
# names_to = "school",
# values_to = "total_screened"
# ) %>%
# pivot_longer(
# cols = c(6:9),
# names_to = "school_percent",
# values_to = "proportion_screened"
# )
```